﻿Imports System.Net
Imports BusinessRule.DTO
Imports BusinessRule.IBusiness
Imports DatabaseAccess.DBUtility

Public Class YPCommonBusiness
    Private m_ContainerObj As New uLMSContainerBusiness
    Private m_CommonObj As New uLMSCommonBusiness

    ''' <summary>
    ''' 获取当前机器IP
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetIP() As Object

        GetIP = ""

        Dim objWMIService, colAdapters, objAdapter As Object
        Dim strComputer = "."
        objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        colAdapters = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
        If colAdapters.Count = 0 Then
            Exit Function
        End If
        If UBound(colAdapters.ItemIndex(0).IPAddress) = 0 Then
            Exit Function
        End If

        GetIP = colAdapters.ItemIndex(0).IPAddress(0)

    End Function

    ''' <summary>
    ''' 同工序多次报工检测项合并 add zhunan 2021.11.17
    ''' </summary>
    ''' <param name="dtSpecs">工序</param>
    ''' <param name="checkerNoEdit">检验员没有录入检测项</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function MergeContainerStepWorkReport(ByVal dtSpecs As DataTable, ByVal checkerNoEdit As Boolean) As DataTable
        If dtSpecs.Rows.Count = 0 Then
            MergeContainerStepWorkReport = dtSpecs
            Exit Function
        End If

        If dtSpecs.Rows.Count > 0 Then
            If Not dtSpecs.Columns.Contains("specid") Then
                MergeContainerStepWorkReport = dtSpecs
                Exit Function
            End If

            If Not dtSpecs.Columns.Contains("isKey") Then
                MergeContainerStepWorkReport = dtSpecs
                Exit Function
            End If
        End If

        dtSpecs.Columns.Add("isSpotCheck")

        If checkerNoEdit Then
            Dim _index As Integer = 1
            For Each dr As DataRow In dtSpecs.Rows
                If dr("isKey").ToString = "1" Then
                    Dim reportPersonCount = dtSpecs.Select(String.Format("specid='{0}'", dr("specid").ToString())).Length
                    If reportPersonCount > 1 Then
                        If _index < reportPersonCount Then
                            '是关键工序，有多条报工记录且当前不是同工序内最后1条记录，不显示
                            dr("isSpotCheck") = "0"
                            _index += 1
                        Else
                            '是关键工序，有多条报工记录且当前是同工序内最后1条记录，显示
                            dr("isSpotCheck") = "1"
                            _index = 1
                        End If
                    Else
                        '是关键工序，但有且只有1条报工记录，显示
                        dr("isSpotCheck") = "1"
                        _index = 1
                    End If
                Else
                    '工序不是关键工序，不显示
                    dr("isSpotCheck") = "0"
                    _index = 1
                End If
            Next
        Else '关键过程序多人报工时，检验员有录入实测值，关键过程信息分开显示
            For Each dr As DataRow In dtSpecs.Rows
                dr("isSpotCheck") = dr("isKey")
            Next
        End If
        MergeContainerStepWorkReport = dtSpecs
    End Function

    ''' <summary>
    ''' 生产关键过程质量控制记录 add zhunan 2021.11.16
    ''' </summary>
    ''' <param name="specid">工序</param>
    ''' <param name="containerstepworkreportid">报工id</param>
    ''' <param name="checkerNoEdit">检验员没有录入检测项</param>
    ''' <param name="dtSpecCheckPoints">检测项</param>
    ''' <param name="dtSpecResource">设备</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function SetSpecKeyQualityControlOld(ByVal specid As String, ByVal containerstepworkreportid As String, ByVal checkerNoEdit As Boolean, ByVal dtSpecCheckPoints As DataTable, ByVal dtSpecResource As DataTable) As String
        Dim resourceLeft As String = "" '设备型号及编号--左侧列
        Dim resourceRight As String = "" '设备型号及编号--右侧列

        Dim rows() As DataRow = dtSpecResource.Select(String.Format("specid='{0}'", specid))

        For i = 0 To rows.Length - 1
            If i Mod 2 = 0 Then
                resourceRight += "<div class='equipmentList'>"
                If rows(i)("isused").ToString() = "1" Then
                    resourceRight += "<span class='listSymbol'>√</span>"
                Else
                    resourceRight += "<span class='listSymbol'>&nbsp;</span>"
                End If
                resourceRight += "<span class='equip-item'>" + rows(i)("resourcename").ToString() + "</span>"
                resourceRight += "</div>"
            Else
                resourceLeft += "<div class='equipmentList'>"
                If rows(i)("isused").ToString() = "1" Then
                    resourceLeft += "<span class='listSymbol'>√</span>"
                Else
                    resourceLeft += "<span class='listSymbol'>&nbsp;</span>"
                End If
                resourceLeft += "<span class='equip-item'>" + rows(i)("resourcename").ToString() + "</span>"
                resourceLeft += "</div>"
            End If
        Next

        Dim guoChengYaoQiuZhi As String = "" '要求值
        Dim guoChengShiJiZhi As String = "" '实际值

        Dim drProcess() As DataRow
        If checkerNoEdit Then
            drProcess = dtSpecCheckPoints.Select(String.Format("specid='{0}' and Checktype = '4'", specid))
        Else
            drProcess = dtSpecCheckPoints.Select(String.Format("specid='{0}' and Checktype = '4' and containerstepworkreportid = '{1}'", specid, containerstepworkreportid))
        End If

        Dim processCount As Integer = IIf(drProcess.Length = 0, 1, drProcess.Length) '过程参数项数

        If drProcess.Length = 0 Then
            guoChengYaoQiuZhi = "<div class='control-item'></div>"
            guoChengShiJiZhi = "<div class='control-item'></div>"
        Else
            For i = 0 To drProcess.Length - 1
                guoChengYaoQiuZhi += "<div class='control-item' title='" + (i + 1).ToString + ". " + drProcess(i)("checkpointnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + drProcess(i)("checkpointnotedis").ToString() + "</div></div>"
                If Not String.IsNullOrEmpty(drProcess(i)("checkpointresultnotedis").ToString()) Then
                    '实测值已录入(检验员)
                    guoChengShiJiZhi += "<div class='control-item' title='" + (i + 1).ToString + ". " + drProcess(i)("checkpointnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + drProcess(i)("checkpointresultnotedis").ToString() + "</div></div>"
                ElseIf Not String.IsNullOrEmpty(drProcess(i)("workcheckpointresultnotedis").ToString()) Then
                    '实测值已录入(报工人)
                    guoChengShiJiZhi += "<div class='control-item' title='" + (i + 1).ToString + ". " + drProcess(i)("checkpointnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + drProcess(i)("workcheckpointresultnotedis").ToString() + "</div></div>"
                Else
                    '实测值未录入
                    guoChengShiJiZhi += "<div class='control-item'><div class='img_warp'></div></div>"
                End If
            Next
        End If

        Dim shejiYaoQiuZhi = "" '设计特性要求值
        Dim shejiShiJiZhi = "" '设计特性实际值

        Dim dtDesign() As DataRow

        If checkerNoEdit Then
            dtDesign = dtSpecCheckPoints.Select(String.Format("specid='{0}' and Checktype = '3'", specid))
        Else
            dtDesign = dtSpecCheckPoints.Select(String.Format("specid='{0}' and Checktype = '3' and containerstepworkreportid = '{1}'", specid, containerstepworkreportid))
        End If

        Dim designCount As Integer = IIf(dtDesign.Length = 0, 1, dtDesign.Length) '设计参数项数

        If dtDesign.Length = 0 Then
            shejiYaoQiuZhi = "<div class='design-item'></div>"
            shejiShiJiZhi = "<div class='design-item'></div>"
        Else
            For i = 0 To dtDesign.Length - 1
                shejiYaoQiuZhi += "<div class='design-item' title='" + (i + 1).ToString + ". " + dtDesign(i)("checkpointnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + dtDesign(i)("checkpointnotedis").ToString() + "</div></div>"
                If Not String.IsNullOrEmpty(dtDesign(i)("checkpointresultnotedis").ToString()) Then
                    '实测值已录入（检验员）
                    shejiShiJiZhi += "<div class='design-item' title='" + (i + 1).ToString + ". " + dtDesign(i)("checkpointresultnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + dtDesign(i)("checkpointresultnotedis").ToString() + "</div></div>"
                ElseIf Not String.IsNullOrEmpty(dtDesign(i)("workcheckpointresultnotedis").ToString()) Then
                    '实测值已录入(报工人)
                    guoChengShiJiZhi += "<div class='design-item' title='" + (i + 1).ToString + ". " + dtDesign(i)("workcheckpointresultnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + dtDesign(i)("workcheckpointresultnotedis").ToString() + "</div></div>"
                Else
                    shejiShiJiZhi += "<div class='design-item'><div class='img_warp'></div></div>" '实测值未录入
                End If
            Next
        End If

        Dim strSpecKeyQualityControl As String = String.Format("" &
            "<div class='key-quality'>" &
                "<!-- 关键过程质量控制记录表头 start -->" &
                "<div style='height: 30px;line-height: 30px;border:1px solid blue;border-top:none;margin-top:0px;'>关键过程质量控制记录</div>" &
                "<!-- 关键过程质量控制记录表头 end -->" &
                "<!-- 设备型号及编号 start -->" &
                "<div class='left' style='overflow:hidden;width:700px;'>" &
                "<!-- 左侧 start -->" &
                "<div class='left' style='width:92px;height:90px;font-size:13px;display:table;'>" &
                    "<div class='vertical-align border-bottom border-right border-left'>" &
                        "<div>设备型号</div>" &
                        "<div>及编号</div>" &
                    "</div>" &
                "</div>" &
                "<!-- 左侧 end -->" &
                "<!-- 中间 start -->" &
                "<div class='left' style='width:400px;height:90px;'>" &
                    "<div class='border-bottom border-right' style='text-align: left;padding-left:5px;overflow: hidden;height:89px;'>" &
                        "<div class='left' style='width:50%;'>" &
                            "<!-- 设备型号及编号左侧列 -->" &
                            "{0}" &
                        "</div>" &
                        "<div class='left' style='width:50%;'>" &
                            "<!-- 设备型号及编号右侧列 -->" &
                            "{1}" &
                        "</div>" &
                    "</div>" &
                "</div>" &
                "<!-- 中间 end -->" &
                "<!-- 右侧 start -->" &
                "<div class='left' style='width:208px;font-size:13px;'>" &
                    "<!-- 第1行 start -->" &
                        "<div class='border-right border-bottom' style='height: 29px;overflow: hidden;'>" &
                            "<div class='left border-right' style='width:60px;height: 30px;line-height:30px;'>批次号</div>" &
                            "<div class='left' style='height: 30px;line-height:30px;'></div>" &
                        "</div>" &
                    "<!-- 第1行 end -->" &
                    "<!-- 第2行 start -->" &
                    "<div style='height: 60px;overflow: hidden;'>" &
                        "<div class='left' style='height:100%;width:100px;'>" &
                            "<div style='height:100%;width:100%;display:table;'>" &
                                "<div class='vertical-align border-bottom border-right' style='font-size:11px;'>" &
                                    "<div>是否符合三定卡</div>" &
                                    "<div>片要求（由检验</div>" &
                                    "<div>员填写是/否）</div>" &
                                "</div>" &
                            "</div>" &
                        "</div>" &
                        "<div class='left' style='height:100%;width:108px;'>" &
                            "<div style='height:100%;width:100%;display:table;'>" &
                                "<div class='vertical-align border-bottom border-right'>" &
                                    "<span class='list-lable'>是</span>" &
                                    "<span class='listSymbol'>&nbsp;</span>" &
                                    "&nbsp;" &
                                    "<span class='list-lable'>否</span>" &
                                    "<span class='listSymbol'>&nbsp;</span>" &
                                "</div>" &
                            "</div>" &
                        "</div>" &
                    "</div>" &
                    "<!-- 第2行 start -->" &
                "</div>" &
                "<!-- 右侧 end -->" &
            "</div>" &
            "<!-- 设备型号及编号 end -->" &
                "<!-- 关键过程控制记录 start -->" &
                "<div>" &
                    "<!-- 第1列 start -->" &
                    "<!-- height: 90 + 行数 * 3 -->" &
                    "<div class='left border-left' style='width:41px;height:" + ((30 + designCount * 30) + 30 * (processCount + 1)).ToString + "px;'>" &
                        "<div style='font-size:13px;height:100%;width:100%;display:table;'>" &
                            "<div class='vertical-align border-bottom border-right'>" &
                                "<div>关键</div>" &
                                "<div>过程</div>" &
                                "<div>控制</div>" &
                                "<div>记录</div>" &
                            "</div>" &
                        "</div>" &
                    "</div>" &
                    "<!-- 第1列 end -->" &
                    "<!-- 第2列 start -->" &
                        "<div class=left style='width:658px;'>" &
                            "<!-- 第1行 start -->" &
                            "<div style='width:100%;height:" + (designCount * 30 + 30).ToString + "px;overflow:hidden;'>" &
                                "<!-- 第1列  start -->" &
                                "<div class='left' style='width:50px;height:100%;'>" &
                                    "<div style='height:" + (designCount * 30 + 30).ToString + "px;'>" &
                                        "<div style='height:100%;width:100%;font-size:13px;display:table;'>" &
                                            "<div class='vertical-align border-bottom border-right'>" &
                                                "<div>设计特</div>" &
                                                "<div>性质量</div>" &
                                                "<div>控制点</div>" &
                                            "</div>" &
                                        "</div>" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第1列 end -->" &
                                "<!-- 第2列 要求值 start -->" &
                                "<div class='left' style='width:400px;height:" + (30 + designCount * 30).ToString + "px;'>" &
                                    "<div class='border-bottom' style='height:" + (30 + designCount * 30 - 1).ToString + "px;font-size:13px;text-align:left;overflow:hidden;'>" &
                                        "<div class='control-item-title'>" &
                                            "要求值：" &
                                        "</div>" &
                                        "<div style='overflow: hidden;height:" + (designCount * 30).ToString + "px'>" &
                                            "<!-- 设计特性--要求值 -->" &
                                            "{2}" &
                                        "</div>" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第2列 要求值 end -->" &
                                "<!-- 第3列 实际值 start -->" &
                                "<div class='left' style='width:208px;height:100%;font-size:13px;position: relative;top:0;left:0;'>" &
                                    "<div class='border-bottom' style='height:" + (60 + (designCount * 30) - 1).ToString + "px;text-align:left;'>" &
                                        "<div class='control-item-title'>" &
                                            "实际（检验员填写）：是否符合" &
                                        "</div>" &
                                        "<!-- height：30 * 设计参数项数 -->" &
                                        "<div style='height:" + (designCount * 30 - 1).ToString + "px;overflow: hidden;border-bottom:1px solid blue;'>" &
                                            "<!-- 设计特性--实际值 -->" &
                                            "{3}" &
                                        "</div>" &
                                        "<div style='height:30px;position: absolute;bottom:0;right:0;'>" &
                                            "<div style='height:100%;width:100%;display:table;'>" &
                                                "<div class='vertical-align' style='text-align:right;'>" &
                                                    "<span class='list-lable'>是</span>" &
                                                    "<span class='listSymbol'>&nbsp;</span>" &
                                                    "&nbsp;&nbsp;" &
                                                    "<span class='list-lable'>否</span>" &
                                                    "<span class='listSymbol' style='margin-right:15px;'>&nbsp;</span>" &
                                                "</div>" &
                                            "</div>" &
                                        "</div>" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第3列 实际值 end -->" &
                            "</div>" &
                            "<!-- 第1行 end -->" &
                            "<!-- 第2行 start -->" &
                            "<!-- height：30 * 行数 -->" &
                            "<div style='width:100%;height:" + (30 * (processCount + 1)).ToString + "px;overflow:hidden;'>" &
                                "<!-- 第1列  start -->" &
                                "<div class='left' style='width:50px;height:100%;'>" &
                                    "<!-- height：30 * 行数 -->" &
                                    "<div style='height:" + (30 * (processCount + 1)).ToString + "px;'>" &
                                        "<div style='height:100%;width:100%;font-size:13px;display:table;'>" &
                                            "<div class='vertical-align border-right border-bottom'>" &
                                                "<div>过程参</div>" &
                                                "<div>数控制</div>" &
                                                "<div>等质量</div>" &
                                                "<div>控制点</div>" &
                                            "</div>" &
                                        "</div>" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第1列 end -->" &
                                "<!-- 第2列 要求值 start -->" &
                                "<!-- height：30 * 行数 -->" &
                                "<div class='left' style='width:400px;height:" + (30 * (processCount + 1)).ToString + "px;'>" &
                                    "<!-- height：30 * 行数 -1 -->" &
                                    "<div class='border-bottom' style='height:" + ((30 * (processCount + 1)) - 1).ToString + "px;font-size:13px;text-align:left;overflow:hidden;'>" &
                                        "<div class='control-item-title'>要求值：</div>" &
                                        "<!-- 过程参数--要求值 -->" &
                                        "{4}" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第2列 要求值 end -->" &
                                "<!-- 第3列 实际 start -->" &
                                "<!-- height：30 * 行数 -->" &
                                "<div class='left' style='width:208px;height:" + (30 * (processCount + 1)).ToString + "px;'>" &
                                    "<!-- height：30 * 行数 -1 -->" &
                                    "<div class='border-bottom' style='height:" + ((30 * (processCount + 1)) - 1).ToString + "px;text-align:left;font-size:13px;overflow:hidden;'>" &
                                        "<div class='control-item-title'>实际值：</div>" &
                                        "<!-- 过程参数--实际值 -->" &
                                        "{5}" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第3列 实际 end -->" &
                            "</div>" &
                            "<!-- 第2行 end -->" &
                        "</div>" &
                        "<!-- 第2列 end -->" &
                        "<div style='clear: both;'></div>" &
                "</div>" &
                "<!-- 关键过程控制记录 end -->" &
            "</div>", resourceLeft, resourceRight, shejiYaoQiuZhi, shejiShiJiZhi, guoChengYaoQiuZhi, guoChengShiJiZhi)
        'resourceLeft,设备型号及编号左侧行
        'resourceRight,设备型号及编号右侧行
        'shejiYaoQiuZhi,设计特性要求值
        'shejiShiJiZhi,设计特性实际值
        'guoChengYaoQiuZhi,过程参数要求值
        'guoChengShiJiZhi过程参数实际值
        SetSpecKeyQualityControlOld = strSpecKeyQualityControl
    End Function

    ''' <summary>
    ''' 生产关键过程质量控制记录 add zhunan 2022.6.15
    ''' </summary>
    ''' <param name="specid">工序id</param>
    ''' <param name="containerstepworkreportid">报工id</param>
    ''' <param name="checkerNoEdit">检验员没有录入检测项</param>
    ''' <param name="dtSpecCheckPoints">检测项</param>
    ''' <param name="dtSpecResource">设备</param>
    ''' <param name="dr">数据行</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function SetSpecKeyQualityControl(ByVal specid As String, ByVal containerstepworkreportid As String, ByVal checkerNoEdit As Boolean, ByVal dtSpecCheckPoints As DataTable, ByVal dtSpecResource As DataTable, ByVal dr As DataRow) As String
        Dim resource As String = ""
        Dim rows() As DataRow = dtSpecResource.Select(String.Format("specid='{0}'", specid))
        For i = 0 To rows.Length - 1
            resource += "<div class='equipmentList'>"
            If rows(i)("isused").ToString() = "1" Then
                resource += "<span class='listSymbol'>√</span>"
            Else
                resource += "<span class='listSymbol'>&nbsp;</span>"
            End If
            resource += "<span class='equip-item'>" + rows(i)("resourcefamilyname").ToString() + "/" + rows(i)("resourcename").ToString() + "</span>"
            resource += "</div>"
        Next

        '关键过程批次号
        Dim keyProcessBatchNo As String = dr("keyprocessbatchno").ToString()

        '是否符合三定卡片要求
        Dim keyProcesIsCheckStr = ""

        If dr.Table.Columns.Contains("checkemployeeid") Then '新增为空判断 add by zhangrj 2022-07-14 
            If dr("checkemployeeid").ToString() <> "" Then
                keyProcesIsCheckStr = "<div class='vertical-align border-bottom border-right'>" &
                                        "<span class='list-lable'>是</span>" &
                                        "<span class='listSymbol'>√</span>&nbsp;" &
                                        "<span class='list-lable'>否</span>" &
                                        "<span class='listSymbol'>&nbsp;</span>" &
                                      "</div>"
            Else
                keyProcesIsCheckStr = "<div class='vertical-align border-bottom border-right'>" &
                                        "<span class='list-lable'>是</span>" &
                                        "<span class='listSymbol'>&nbsp;</span>&nbsp;" &
                                        "<span class='list-lable'>否</span>" &
                                        "<span class='listSymbol'>&nbsp;</span>" &
                                      "</div>"
            End If
        Else
            keyProcesIsCheckStr = "<div class='vertical-align border-bottom border-right'>" &
                                       "<span class='list-lable'>是</span>" &
                                       "<span class='listSymbol'>&nbsp;</span>&nbsp;" &
                                       "<span class='list-lable'>否</span>" &
                                       "<span class='listSymbol'>&nbsp;</span>" &
                                     "</div>"
        End If

        Dim guoChengYaoQiuZhi As String = "" '要求值
        Dim guoChengShiJiZhi As String = "" '实际值

        Dim drProcess = dtSpecCheckPoints.Select(String.Format("specid='{0}' and Checktype = '4'", specid))
        Dim processCount As Integer = IIf(drProcess.Length = 0, 1, drProcess.Length) '过程参数项数

        If drProcess.Length = 0 Then
            guoChengYaoQiuZhi = "<div class='control-item'></div>"
            guoChengShiJiZhi = "<div class='control-item'></div>"
        Else
            For i = 0 To drProcess.Length - 1
                guoChengYaoQiuZhi += "<div class='control-item' title='" + (i + 1).ToString + ". " + drProcess(i)("DrawingRequire").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + drProcess(i)("DrawingRequire").ToString() + "</div></div>"
                If Not String.IsNullOrEmpty(drProcess(i)("checkpointresultnotedis").ToString()) Then
                    '实测值已录入(检验员)
                    guoChengShiJiZhi += "<div class='control-item' title='" + (i + 1).ToString + ". " + drProcess(i)("checkpointnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + drProcess(i)("checkpointresultnotedis").ToString() + "</div></div>"
                ElseIf drProcess(i).Table.Columns.Contains("workcheckpointresultnotedis") Then '新增为空判断 add by zhangrj 2022-07-14 
                    If Not String.IsNullOrEmpty(drProcess(i)("workcheckpointresultnotedis").ToString()) Then
                        '实测值已录入(报工人)
                        guoChengShiJiZhi += "<div class='control-item' title='" + (i + 1).ToString + ". " + drProcess(i)("checkpointnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + drProcess(i)("workcheckpointresultnotedis").ToString() + "</div></div>"
                    End If
                Else
                    '实测值未录入
                    guoChengShiJiZhi += "<div class='control-item'><div class='img_warp'></div></div>"
                End If
            Next
        End If

        Dim shejiYaoQiuZhi = "" '设计特性要求值
        Dim shejiShiJiZhi = "" '设计特性实际值

        Dim dtDesign = dtSpecCheckPoints.Select(String.Format("specid='{0}' and Checktype = '3'", specid))
        Dim designCount As Integer = IIf(dtDesign.Length = 0, 1, dtDesign.Length) '设计参数项数

        If dtDesign.Length = 0 Then
            shejiYaoQiuZhi = "<div class='design-item'></div>"
            shejiShiJiZhi = "<div class='design-item'></div>"
        Else
            For i = 0 To dtDesign.Length - 1
                shejiYaoQiuZhi += "<div class='design-item' title='" + (i + 1).ToString + ". " + dtDesign(i)("DrawingRequire").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + dtDesign(i)("DrawingRequire").ToString() + "</div></div>"
                If Not String.IsNullOrEmpty(dtDesign(i)("checkpointresultnotedis").ToString()) Then
                    '实测值已录入（检验员）
                    shejiShiJiZhi += "<div class='design-item' title='" + (i + 1).ToString + ". " + dtDesign(i)("checkpointresultnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + dtDesign(i)("checkpointresultnotedis").ToString() + "</div></div>"
                ElseIf dtDesign(i).Table.Columns.Contains("workcheckpointresultnotedis") Then '新增为空判断 add by zhangrj 2022-07-14 
                    If Not String.IsNullOrEmpty(dtDesign(i)("workcheckpointresultnotedis").ToString()) Then
                        '实测值已录入(报工人)
                        shejiShiJiZhi += "<div class='design-item' title='" + (i + 1).ToString + ". " + dtDesign(i)("workcheckpointresultnotedis").ToString() + "'><div class='img_warp'>" + (i + 1).ToString + ". " + dtDesign(i)("workcheckpointresultnotedis").ToString() + "</div></div>"
                    End If
                Else
                    shejiShiJiZhi += "<div class='design-item'><div class='img_warp'></div></div>" '实测值未录入
                End If
            Next
        End If

        Dim strSpecKeyQualityControl As String = String.Format("" &
            "<div class='key-quality'>" &
                "<!-- 关键过程质量控制记录表头 start -->" &
                "<div style='height: 30px;line-height: 30px;border:1px solid blue;border-top:none;margin-top:0px;'>关键过程质量控制记录</div>" &
                "<!-- 关键过程质量控制记录表头 end -->" &
                "<!-- 设备型号及编号 start -->" &
                "<div class='left' style='overflow:hidden;width:700px;'>" &
                "<!-- 左侧 start -->" &
                "<div class='left' style='width:92px;height:90px;font-size:13px;display:table;'>" &
                    "<div class='vertical-align border-bottom border-right border-left'>" &
                        "<div>设备型号</div>" &
                        "<div>及编号</div>" &
                    "</div>" &
                "</div>" &
                "<!-- 左侧 end -->" &
                "<!-- 中间 start -->" &
                "<div class='left' style='width:400px;height:90px;'>" &
                    "<div class='border-bottom border-right' style='text-align: left;padding-left:5px;overflow: hidden;height:89px;'>" &
                        "<div>" &
                            "<!-- 设备型号及编号 -->" &
                            "{0}" &
                        "</div>" &
                    "</div>" &
                "</div>" &
                "<!-- 中间 end -->" &
                "<!-- 右侧 start -->" &
                "<div class='left' style='width:208px;font-size:13px;'>" &
                    "<!-- 第1行 start -->" &
                        "<div class='border-right border-bottom' style='height: 29px;overflow: hidden;'>" &
                            "<div class='left border-right' style='width:60px;height: 30px;line-height:30px;'>批次号</div>" &
                            "<div style='height: 30px;line-height:15px;word-break:break-all;font-size: 10px;text-align: left;'>" &
                                "<!-- 关键过程批次号 -->" &
                                "<div style='padding-left: 65px;' title='{1}'>" &
                                    "{1}" &
                                "</div>" &
                            "</div>" &
                        "</div>" &
                    "<!-- 第1行 end -->" &
                    "<!-- 第2行 start -->" &
                    "<div style='height: 60px;overflow: hidden;'>" &
                        "<div class='left' style='height:100%;width:100px;'>" &
                            "<div style='height:100%;width:100%;display:table;'>" &
                                "<div class='vertical-align border-bottom border-right' style='font-size:11px;'>" &
                                    "<div>是否符合三定卡</div>" &
                                    "<div>片要求（由检验</div>" &
                                    "<div>员填写是/否）</div>" &
                                "</div>" &
                            "</div>" &
                        "</div>" &
                        "<div class='left' style='height:100%;width:108px;'>" &
                            "<div style='height:100%;width:100%;display:table;'>" &
                                "<!-- 是否符合三定卡片要求 -->" &
                                "{2}" &
                            "</div>" &
                        "</div>" &
                    "</div>" &
                    "<!-- 第2行 start -->" &
                "</div>" &
                "<!-- 右侧 end -->" &
            "</div>" &
            "<!-- 设备型号及编号 end -->" &
                "<!-- 关键过程控制记录 start -->" &
                "<div>" &
                    "<!-- 第1列 start -->" &
                    "<!-- height: 90 + 行数 * 3 -->" &
                    "<div class='left border-left' style='width:41px;height:" + ((30 + designCount * 30) + 30 * (processCount + 1)).ToString + "px;'>" &
                        "<div style='font-size:13px;height:100%;width:100%;display:table;'>" &
                            "<div class='vertical-align border-bottom border-right'>" &
                                "<div>关键</div>" &
                                "<div>过程</div>" &
                                "<div>控制</div>" &
                                "<div>记录</div>" &
                            "</div>" &
                        "</div>" &
                    "</div>" &
                    "<!-- 第1列 end -->" &
                    "<!-- 第2列 start -->" &
                        "<div class=left style='width:658px;'>" &
                            "<!-- 第1行 start -->" &
                            "<div style='width:100%;height:" + (designCount * 30 + 30).ToString + "px;overflow:hidden;'>" &
                                "<!-- 第1列  start -->" &
                                "<div class='left' style='width:50px;height:100%;'>" &
                                    "<div style='height:" + (designCount * 30 + 30).ToString + "px;'>" &
                                        "<div style='height:100%;width:100%;font-size:13px;display:table;'>" &
                                            "<div class='vertical-align border-bottom border-right'>" &
                                                "<div>设计特</div>" &
                                                "<div>性质量</div>" &
                                                "<div>控制点</div>" &
                                            "</div>" &
                                        "</div>" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第1列 end -->" &
                                "<!-- 第2列 要求值 start -->" &
                                "<div class='left' style='width:400px;height:" + (30 + designCount * 30).ToString + "px;'>" &
                                    "<div class='border-bottom' style='height:" + (30 + designCount * 30 - 1).ToString + "px;font-size:13px;text-align:left;overflow:hidden;'>" &
                                        "<div class='control-item-title'>" &
                                            "要求值：" &
                                        "</div>" &
                                        "<div style='overflow: hidden;height:" + (designCount * 30).ToString + "px'>" &
                                            "<!-- 设计特性--要求值 -->" &
                                            "{3}" &
                                        "</div>" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第2列 要求值 end -->" &
                                "<!-- 第3列 实际值 start -->" &
                                "<div class='left' style='width:208px;height:100%;font-size:13px;position: relative;top:0;left:0;'>" &
                                    "<div class='border-bottom' style='height:" + (60 + (designCount * 30) - 1).ToString + "px;text-align:left;'>" &
                                        "<div class='control-item-title'>" &
                                            "实际（检验员填写）：是否符合" &
                                        "</div>" &
                                        "<!-- height：30 * 设计参数项数 -->" &
                                        "<div style='height:" + (designCount * 30 - 1).ToString + "px;overflow: hidden;border-bottom:1px solid blue;'>" &
                                            "<!-- 设计特性--实际值 -->" &
                                            "{4}" &
                                        "</div>" &
                                        "<div style='height:30px;position: absolute;bottom:0;right:0;'>" &
                                            "<div style='height:100%;width:100%;display:table;'>" &
                                                "<!--<div class='vertical-align' style='text-align:right;'>" &
                                                    "<span class='list-lable'>是</span>" &
                                                    "<span class='listSymbol'>&nbsp;</span>" &
                                                    "&nbsp;&nbsp;" &
                                                    "<span class='list-lable'>否</span>" &
                                                    "<span class='listSymbol' style='margin-right:15px;'>&nbsp;</span>" &
                                                "</div>-->" &
                                            "</div>" &
                                        "</div>" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第3列 实际值 end -->" &
                            "</div>" &
                            "<!-- 第1行 end -->" &
                            "<!-- 第2行 start -->" &
                            "<!-- height：30 * 行数 -->" &
                            "<div style='width:100%;height:" + (30 * (processCount + 1)).ToString + "px;overflow:hidden;'>" &
                                "<!-- 第1列  start -->" &
                                "<div class='left' style='width:50px;height:100%;'>" &
                                    "<!-- height：30 * 行数 -->" &
                                    "<div style='height:" + (30 * (processCount + 1)).ToString + "px;'>" &
                                        "<div style='height:100%;width:100%;font-size:12.7px;display:table;'>" &
                                            "<div class='vertical-align border-right border-bottom'>" &
                                                "<div>过程参</div>" &
                                                "<div>数控制</div>" &
                                                "<div>等质量</div>" &
                                                "<div>控制点</div>" &
                                            "</div>" &
                                        "</div>" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第1列 end -->" &
                                "<!-- 第2列 要求值 start -->" &
                                "<!-- height：30 * 行数 -->" &
                                "<div class='left' style='width:400px;height:" + (30 * (processCount + 1)).ToString + "px;'>" &
                                    "<!-- height：30 * 行数 -1 -->" &
                                    "<div class='border-bottom' style='height:" + ((30 * (processCount + 1)) - 1).ToString + "px;font-size:13px;text-align:left;overflow:hidden;'>" &
                                        "<div class='control-item-title'>要求值：</div>" &
                                        "<!-- 过程参数--要求值 -->" &
                                        "{5}" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第2列 要求值 end -->" &
                                "<!-- 第3列 实际 start -->" &
                                "<!-- height：30 * 行数 -->" &
                                "<div class='left' style='width:208px;height:" + (30 * (processCount + 1)).ToString + "px;'>" &
                                    "<!-- height：30 * 行数 -1 -->" &
                                    "<div class='border-bottom' style='height:" + ((30 * (processCount + 1)) - 1).ToString + "px;text-align:left;font-size:13px;overflow:hidden;'>" &
                                        "<div class='control-item-title'>实际值：</div>" &
                                        "<!-- 过程参数--实际值 -->" &
                                        "{6}" &
                                    "</div>" &
                                "</div>" &
                                "<!-- 第3列 实际 end -->" &
                            "</div>" &
                            "<!-- 第2行 end -->" &
                        "</div>" &
                        "<!-- 第2列 end -->" &
                        "<div style='clear: both;'></div>" &
                "</div>" &
                "<!-- 关键过程控制记录 end -->" &
            "</div>", resource, keyProcessBatchNo, keyProcesIsCheckStr, shejiYaoQiuZhi, shejiShiJiZhi, guoChengYaoQiuZhi, guoChengShiJiZhi)
        'resource,设备型号及编号
        'keyProcessBatchNo 关键过程批次号
        'keyProcesIsCheckStr 是否符合三定卡片要求
        'shejiYaoQiuZhi,设计特性要求值
        'shejiShiJiZhi,设计特性实际值
        'guoChengYaoQiuZhi,过程参数要求值
        'guoChengShiJiZhi过程参数实际值
        SetSpecKeyQualityControl = strSpecKeyQualityControl
    End Function

    ''' <summary>
    ''' 设置该批次的同工艺批次上一次已校对，跳过此次开卡校对数据（叶片） add by zhangrj 20220714
    ''' </summary>
    ''' <param name="containerBaseInfo"></param>
    ''' <param name="msg"></param>
    ''' <remarks></remarks>
    Public Function SetSameWorkflowProofreadContainer(ByRef containerBaseInfo As ContainerStartInfo, ByRef msg As String) As Boolean
        msg = ""
        Dim dtSameWorkflowVerifiedContainer As DataTable = m_ContainerObj.GetSameWorkflowVerifiedContainer(containerBaseInfo.MfgWorkflowName, containerBaseInfo.MfgWorkflowRevision)
        '同工艺存在已校对批次
        If dtSameWorkflowVerifiedContainer.Rows.Count > 0 Then
            '不领料，直接进入'物料检验'
            If containerBaseInfo.IsSelfMfg Then
                containerBaseInfo.WorkflowStep = "物料检验"

            Else '如果领料，先判断材料牌号是否有钛合金
                Dim strSql = "SELECT y.istitanium FROM yptitaniummaterial y" +
" LEFT JOIN  product p ON p.materialtrademark = y.materialtrademark" +
" LEFT JOIN productbase pb ON pb.productbaseid = p.productbaseid" +
" WHERE pb.productname = '{0}' AND p.productrevision = '{1}'"
                strSql = String.Format(strSql, containerBaseInfo.ProductName, containerBaseInfo.ProductRevision)
                Dim temp As DataTable = DatabaseHelper.Query_ReturnDatTable(strSql)

                If temp.Rows.Count = 0 Then '如果材料牌号没有维护钛合金，不让开卡
                    msg = "未维护钛合金"
                    Return False
                    Exit Function
                End If
                If temp.Rows(0)("ISTITANIUM").ToString = "0" Then '如果材料牌号不是钛合金材料，则跳到'物料检验'
                    containerBaseInfo.WorkflowStep = "物料检验"
                Else '材料牌号是钛合金,移动到'温度确认'
                    containerBaseInfo.WorkflowStep = "温度确认"
                End If
            End If
            '将当前工艺上一次开卡批次的校对信息保存至批次属性表,格式如下:
            'userattributename: 工艺校对
            'attributevalue: 校对日期&校对人id
            Dim attrDt As DataTable = containerBaseInfo.AttributeList
            Dim row As DataRow = attrDt.NewRow
            '针对特种开卡没有这两列
            If attrDt.Columns.Contains("ContainerName") Then
                row("ContainerName") = containerBaseInfo.ContainerName
                row("Level") = containerBaseInfo.Level
            End If
            row("Name") = "工艺校对"
            row("Value") = dtSameWorkflowVerifiedContainer.Rows(0)("techniquedate").ToString + "&" + dtSameWorkflowVerifiedContainer.Rows(0)("techniqueemployeeid").ToString
            containerBaseInfo.AttributeList.Rows.Add(row)
        End If
        Return True
    End Function

    ''' <summary>
    ''' 获取机加批次平行作业工序
    ''' </summary>
    ''' <param name="containerBaseInfo"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetMacheExtraWorkStep(ByVal containerBaseInfo As ContainerStartInfo) As DataTable
        Dim strSql As String = <string>
 SELECT y.* FROM Collecterpmaterial cl
LEFT JOIN container c ON c.containername = cl.productname||'/'||replace(replace(cl.productbatchno,'.',''),' ','')
LEFT JOIN ypmacheextrawork y ON y.containerid = c.containerid
WHERE cl.mfgordername = '{0}' AND y.ypmacheextraworkid IS NOT NULL
                               </string>.Value
        strSql = String.Format(strSql, containerBaseInfo.MfgOrder)
        Return DatabaseHelper.Query_ReturnDatTable(strSql)
    End Function

End Class
